<!DOCTYPE html>
<html ng-app="demoApp">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Toast 通知 - ng-components-ui</title>
    <link rel="stylesheet" href="../dist/ng-components.css" />
    <style>
      * {
        box-sizing: border-box;
      }

      body {
        font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
          "Helvetica Neue", Arial, sans-serif;
        margin: 0;
        padding: 0;
        background: #f5f5f5;
      }

      .header {
        background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
        color: white;
        padding: 30px 40px;
        box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
      }

      .header h1 {
        margin: 0 0 10px 0;
        font-size: 32px;
      }

      .header p {
        margin: 0;
        opacity: 0.9;
        font-size: 16px;
      }

      .back-link {
        display: inline-block;
        margin-top: 15px;
        color: white;
        text-decoration: none;
        padding: 8px 16px;
        background: rgba(255, 255, 255, 0.2);
        border-radius: 4px;
        transition: background 0.2s;
      }

      .back-link:hover {
        background: rgba(255, 255, 255, 0.3);
      }

      .container {
        max-width: 1400px;
        margin: 0 auto;
        padding: 40px;
      }

      .demo-section {
        background: white;
        padding: 30px;
        border-radius: 8px;
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
        margin-bottom: 30px;
      }

      .demo-section h2 {
        margin: 0 0 20px 0;
        color: #333;
        font-size: 20px;
        border-bottom: 2px solid #667eea;
        padding-bottom: 10px;
      }

      .demo-section h3 {
        margin: 20px 0 15px 0;
        color: #555;
        font-size: 16px;
        font-weight: 600;
      }

      .demo-section p {
        color: #666;
        line-height: 1.6;
        margin: 0 0 15px 0;
      }

      .demo-actions {
        display: flex;
        gap: 15px;
        flex-wrap: wrap;
        margin: 20px 0;
      }

      .btn {
        padding: 10px 20px;
        border: none;
        border-radius: 6px;
        cursor: pointer;
        font-size: 14px;
        font-weight: 500;
        transition: all 0.2s;
        box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
      }

      .btn:hover {
        transform: translateY(-2px);
        box-shadow: 0 4px 8px rgba(0, 0, 0, 0.15);
      }

      .btn:active {
        transform: translateY(0);
      }

      .btn-primary {
        background: #667eea;
        color: white;
      }

      .btn-success {
        background: #48bb78;
        color: white;
      }

      .btn-warning {
        background: #ed8936;
        color: white;
      }

      .btn-danger {
        background: #f56565;
        color: white;
      }

      .btn-info {
        background: #4299e1;
        color: white;
      }

      .btn-secondary {
        background: #a0aec0;
        color: white;
      }

      .code-block {
        background: #f7fafc;
        border: 1px solid #e2e8f0;
        border-radius: 4px;
        padding: 15px;
        margin: 10px 0;
        font-family: "Monaco", "Menlo", "Ubuntu Mono", monospace;
        font-size: 12px;
        overflow-x: auto;
      }

      .code-block code {
        color: #2d3748;
      }

      .feature-list {
        background: #f7fafc;
        border-left: 4px solid #667eea;
        padding: 15px 20px;
        margin: 20px 0;
      }

      .feature-list ul {
        margin: 0;
        padding-left: 20px;
      }

      .feature-list li {
        color: #4a5568;
        margin: 8px 0;
        line-height: 1.6;
      }
    </style>
  </head>
  <body ng-controller="DemoController">
    <!-- Toast 容器 -->
    <ng-toast-container></ng-toast-container>

    <div class="header">
      <h1>Toast 通知组件</h1>
      <p>轻量级消息通知，支持多种类型和自动关闭</p>
      <a href="home.html" class="back-link">← 返回主页</a>
    </div>

    <div class="container">
      <div class="demo-section">
        <h2>Toast 通知 (ng-toast)</h2>

        <div class="feature-list">
          <strong>功能特性:</strong>
          <ul>
            <li>支持 success、info、warning、danger 四种类型</li>
            <li>自动关闭，可配置显示时长</li>
            <li>可手动关闭通知</li>
            <li>队列管理，控制同时显示的通知数量</li>
            <li>轻量级非阻塞式设计</li>
          </ul>
        </div>

        <h3>1. 基本用法</h3>
        <p>使用 ngToast 服务显示不同类型的通知</p>
        <div class="demo-actions">
          <button class="btn btn-success" ng-click="showSuccess()">
            成功通知
          </button>
          <button class="btn btn-info" ng-click="showInfo()">
            信息通知
          </button>
          <button class="btn btn-warning" ng-click="showWarning()">
            警告通知
          </button>
          <button class="btn btn-danger" ng-click="showDanger()">
            错误通知
          </button>
        </div>

        <div class="code-block">
          <code>
// 成功通知<br>
ngToast.success('操作成功！');<br>
<br>
// 信息通知<br>
ngToast.info('这是一条信息');<br>
<br>
// 警告通知<br>
ngToast.warning('请注意！');<br>
<br>
// 错误通知<br>
ngToast.danger('操作失败！');
          </code>
        </div>

        <h3>2. 自定义配置</h3>
        <p>可以自定义通知的显示时长、是否可关闭等</p>
        <div class="demo-actions">
          <button class="btn btn-primary" ng-click="showLongDuration()">
            长时间显示（5秒）
          </button>
          <button class="btn btn-primary" ng-click="showNoDismiss()">
            不可手动关闭
          </button>
          <button class="btn btn-primary" ng-click="showPermanent()">
            永久显示
          </button>
        </div>

        <div class="code-block">
          <code>
// 长时间显示<br>
ngToast.info({<br>
&nbsp;&nbsp;message: '这条消息会显示 5 秒',<br>
&nbsp;&nbsp;duration: 5000<br>
});<br>
<br>
// 不可手动关闭<br>
ngToast.info({<br>
&nbsp;&nbsp;message: '不能手动关闭',<br>
&nbsp;&nbsp;dismissible: false,<br>
&nbsp;&nbsp;duration: 2000<br>
});<br>
<br>
// 永久显示（需手动关闭）<br>
ngToast.info({<br>
&nbsp;&nbsp;message: '需要手动关闭',<br>
&nbsp;&nbsp;duration: 0,<br>
&nbsp;&nbsp;dismissible: true<br>
});
          </code>
        </div>

        <h3>3. 批量操作</h3>
        <p>测试队列管理和批量操作</p>
        <div class="demo-actions">
          <button class="btn btn-secondary" ng-click="showMultiple()">
            显示多条通知
          </button>
          <button class="btn btn-secondary" ng-click="clearAll()">
            清空所有通知
          </button>
        </div>

        <div class="code-block">
          <code>
// 显示多条通知<br>
for (var i = 0; i < 5; i++) {<br>
&nbsp;&nbsp;ngToast.info('通知 ' + (i + 1));<br>
}<br>
<br>
// 清空所有通知<br>
ngToast.clearAll();
          </code>
        </div>

        <h3>4. 实际应用场景</h3>
        <div class="demo-actions">
          <button class="btn btn-success" ng-click="saveSuccess()">
            保存成功
          </button>
          <button class="btn btn-danger" ng-click="deleteError()">
            删除失败
          </button>
          <button class="btn btn-warning" ng-click="networkWarning()">
            网络异常
          </button>
        </div>
      </div>
    </div>

    <script src="https://cdn.jsdelivr.net/npm/angular@1.8.3/angular.min.js"></script>
    <script src="https://cdn.jsdelivr.net/npm/angular-strap@2.3.12/dist/angular-strap.min.js"></script>
    <script src="../dist/ng-components.js"></script>
    <script>
      angular
        .module("demoApp", ["ngComponents"])
        .controller("DemoController", function ($scope, ngToast) {
          // 基本用法
          $scope.showSuccess = function () {
            ngToast.success("操作成功！");
          };

          $scope.showInfo = function () {
            ngToast.info("这是一条信息通知");
          };

          $scope.showWarning = function () {
            ngToast.warning("请注意，这是警告信息！");
          };

          $scope.showDanger = function () {
            ngToast.danger("操作失败，请重试！");
          };

          // 自定义配置
          $scope.showLongDuration = function () {
            ngToast.info({
              message: "这条消息会显示 5 秒",
              duration: 5000
            });
          };

          $scope.showNoDismiss = function () {
            ngToast.info({
              message: "不能手动关闭，2秒后自动关闭",
              dismissible: false,
              duration: 2000
            });
          };

          $scope.showPermanent = function () {
            ngToast.info({
              message: "需要手动关闭这条消息",
              duration: 0,
              dismissible: true
            });
          };

          // 批量操作
          $scope.showMultiple = function () {
            for (var i = 0; i < 5; i++) {
              ngToast.info("通知消息 " + (i + 1));
            }
          };

          $scope.clearAll = function () {
            ngToast.clearAll();
          };

          // 实际应用场景
          $scope.saveSuccess = function () {
            ngToast.success("数据保存成功！");
          };

          $scope.deleteError = function () {
            ngToast.danger("删除失败，该项目正在使用中");
          };

          $scope.networkWarning = function () {
            ngToast.warning("网络连接不稳定，请检查网络设置");
          };
        });
    </script>
  </body>
</html>
